package com.qkl.xiatang.app.entity.device;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

@Data
@TableName(value = "sensor_type_sort")
public class SensorTypeSortEntity {

    @TableId(type= IdType.ASSIGN_ID)
    private String id;

    private String companyId;

    private String userId;

    private String sensorId;

    private String sortJson;

    public List<Integer> toSort(){
        if(StringUtils.isEmpty(sortJson)){
            return new ArrayList<>();
        }
        return JSON.parseArray(sortJson,Integer.TYPE);
    }
}
